#!/usr/bin/python
# -*- coding: utf-8 -*-

"""
Mir production

First TU of the application
in the titlebar of the window.

author: AM NB PM
last edited: 02/09/13
"""

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui  import *
from trilinux     import *
from mainwindow import Ui_MainWindow


class MIR(QMainWindow):
    def __init__(self,parent=None):
        super (MIR, self).__init__(parent)
        self.ui=Ui_MainWindow()
        self.ui.setupUi(self)
        QObject.connect(self.ui.listWidget,SIGNAL("itemClicked(QListWidgetItem*)"),self.filmSelected)
        QObject.connect(self.ui.pushButton,SIGNAL("clicked()"),self.SelectFilm)

#        self.ui.webView.load(QUrl("http://qt.nokia.com/"))
        self.ui.listWidget.addItem("fight club")
        self.ui.listWidget.addItem("snatch")

        self.ui.listWidget.addItem("Le roi lion")
        self.ui.listWidget.addItem("Leon")
#        print getMovieHtmlPage(".f/fight club.avi")

    def addFilm(self):
        self.ui.listWidget.addItem("toto")
        start()

    def filmSelected(self, item):
        self.ui.webView.setUrl(QUrl(getMoviePageWithTitle(item.text())))


    def SelectFilm(self):
        print "dfdfd"+getAuthor(self.ui.webView.page().mainFrame().toHtml())
        self.ui.lineEditAuthor.setText(getAuthor(self.ui.webView.page().mainFrame().toHtml()))
        self.ui.lineEditTitle.setText(self.ui.listWidget.currentItem().text())
        self.ui.plainTextEdit.clear()
        self.ui.plainTextEdit.appendPlainText(getSynopsis(self.ui.webView.page().mainFrame().toHtml()))

def main():
    
    app = QApplication(sys.argv)
    ex = MIR()
    ex.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()   
